<?php
require_once './include/common.inc.php';
checkLogin();

getMyParam('type');
getMyParam('id');

if ($type == 'category') {
    $sql = "SELECT `id`, `e_catalogue` FROM `category` WHERE `id` = $id";
    $tmp_ary = $db->get_one($sql);
    $filename = $tmp_ary['e_catalogue'];
    $path = "./zh/attachments/" . $filename;
} else {
    header("Location:index.php");
}

header("Content-type:application/pdf");
header("Accept-Ranges:bytes");
header("Content-Disposition:attachment;filename=".$filename);

$content = file_get_contents($path);
echo $content;

?>